using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace RandomGenerator
{
    class ListGenerator
    {
        public List<string> GenList(int Level, string GameMode)
        {
            // Get a set of colors and place them in a list
            List<string> Sequence = new List<string>();
            if (GameMode == "Single")
            {
                for (int i = 0; i < Level; i++)
                {
                    Sequence.Add(GetRandColor());
                    System.Threading.Thread.Sleep(15);
                }
            } else if (GameMode == "Multi")
            {
                for (int i = 0; i < Level; i++)
                {
                    string firstCol = GetRandColor();
                    System.Threading.Thread.Sleep(15);
                    string secondCol = GetRandColor();
                    string curColor = "";

                    if (firstCol != secondCol)
                    {
                        System.Threading.Thread.Sleep(15);
                        firstCol = GetRandColor();

                        if (firstCol != secondCol)
                        {
                            curColor = firstCol + "," + secondCol;
                        } 
                        else
                        {
                            curColor = firstCol;
                        }
                    }
                    else
                    {
                        curColor = firstCol;
                    }

                    Sequence.Add(curColor);
                    System.Threading.Thread.Sleep(15);
                }
            }
            return Sequence;
        }


        public string GetRandColor()
        {
            Random Rnd = new Random();
            string sndColor = "";
            int RndNum = Rnd.Next(0, 4);  // Rand 0-3

            // Convert numbers to color strings
            switch (RndNum)
            {
                case 0:
                    sndColor = "Blue";
                    break;
                case 1:
                    sndColor = "Yellow";
                    break;
                case 2:
                    sndColor = "Green";
                    break;
                case 3:
                    sndColor = "Red";
                    break;
            }
            return sndColor;
        }
}
}